#include "StdAfx.h"
#include "TTChatClient.h"
#include "TTChatConnectionListener.h"

CTTChatConnectionListener::CTTChatConnectionListener(void)
{
}

CTTChatConnectionListener::CTTChatConnectionListener( CTTChatClient* pClient )
{
	m_pClient=NULL;
	ASSERT(pClient);

	m_pClient=pClient;
}

CTTChatConnectionListener::~CTTChatConnectionListener(void)
{
}

void CTTChatConnectionListener::onConnect()
{
	ASSERT( m_pClient != NULL );
	if ( m_pClient != NULL )
	{
		SendMessage(m_pClient->m_hConnWnd,TTChatGlobal::TM_CONNECT_NOTIFY,NULL,NULL);
	}
}

void CTTChatConnectionListener::onDisconnect( enum gloox::ConnectionError e )
{
	ASSERT( m_pClient != NULL );

	if(IsWindow(m_pClient->m_hConnWnd))
		SendMessage(m_pClient->m_hConnWnd,TTChatGlobal::TM_DISCONN_NOTIFY,e,NULL);
	if(IsWindow(m_pClient->m_hMainWnd))
		SendMessage(m_pClient->m_hMainWnd,TTChatGlobal::TM_DISCONN_NOTIFY,e,NULL);
}

bool CTTChatConnectionListener::onTLSConnect( const struct gloox::CertInfo& )
{
	return true;
}
